package com.financing.wap.service.impl;

import java.math.BigDecimal;
import java.sql.SQLException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.financing.wap.vo.YouDanAmountVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.financing.wap.dao.IYouDanAmountDao;
import com.financing.wap.dto.YouDanAmountDTO;
import com.financing.wap.service.IYouDanAmountService;
import com.financing.wap.vo.YouDanAmountVO;


/**
 * 有单金额明细相关
 * @author cuimo
 *
 */
@Service("youDanAmountServiceImpl")
@Transactional
public class YouDanAmountServiceImpl extends BaseServiceImpl implements IYouDanAmountService {

	
	@Autowired
	private IYouDanAmountDao youDanAmountDaoImpl;

	@Override
	public int updateYouDanAmount(YouDanAmountDTO youDanAmount) throws SQLException {
		return youDanAmountDaoImpl.updateYouDanAmount(youDanAmount);
	}

	@Override
	public Integer insertYouDanAmount(YouDanAmountDTO youDanAmount) throws SQLException {
		return youDanAmountDaoImpl.insertYouDanAmount(youDanAmount);
	}
	
	@Override
	public List<YouDanAmountDTO> getYouDanAmount(YouDanAmountVO youDanAmount) throws SQLException {
		return youDanAmountDaoImpl.getYouDanAmount(youDanAmount);
	}
	
	@Override
	public int updateBaoZhengJin2Lock(Integer receiptId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("01");
		youDanAmount.setAssociationId(receiptId);
		youDanAmount.setOperateType("01");
		youDanAmount.setRemark(remark);
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateBaoZhengJin2Unlock(Integer receiptId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("01");
		youDanAmount.setAssociationId(receiptId);
		youDanAmount.setOperateType("02");
		youDanAmount.setRemark(remark);
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateBaoZhengJin2Withdraw(Integer receiptId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("01");
		youDanAmount.setAssociationId(receiptId);
		youDanAmount.setOperateType("03");
		youDanAmount.setRemark(remark);
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateBaoZhengJin2WithdrawSuccess(Integer receiptId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("01");
		youDanAmount.setAssociationId(receiptId);
		youDanAmount.setOperateType("04");
		youDanAmount.setRemark(remark);
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateBaoZhengJin2WithdrawFail(Integer receiptId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("01");
		youDanAmount.setAssociationId(receiptId);
		youDanAmount.setOperateType("05");
		youDanAmount.setRemark(remark);
		return this.updateYouDanAmount(youDanAmount);
	}
	
	@Override
	public int updateBaoZhengJin2Fail(Integer receiptId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("01");
		youDanAmount.setAssociationId(receiptId);
		youDanAmount.setOperateType("06");
		youDanAmount.setRemark(remark);
		return this.updateYouDanAmount(youDanAmount);
	}


	@Override
	public int updateYongJin2Lock(Integer orderId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("02");
		youDanAmount.setAssociationId(orderId);
		youDanAmount.setOperateType("01");
		youDanAmount.setRemark(remark);
		youDanAmount.setAmountType("02");//02 接受保证金
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateYongJin2Unlock(Integer orderId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("02");
		youDanAmount.setAssociationId(orderId);
		youDanAmount.setOperateType("02");
		youDanAmount.setRemark(remark);
		youDanAmount.setAmountType("02");//02 接受保证金
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateYongJin2Withdraw(Integer orderId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("02");
		youDanAmount.setAssociationId(orderId);
		youDanAmount.setOperateType("03");
		youDanAmount.setRemark(remark);
		youDanAmount.setAmountType("02");//02 接受保证金
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateYongJin2WithdrawSuccess(Integer orderId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("02");
		youDanAmount.setAssociationId(orderId);
		youDanAmount.setOperateType("04");
		youDanAmount.setRemark(remark);
		youDanAmount.setAmountType("02");//02 接受保证金
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateYongJin2WithdrawFail(Integer orderId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("02");
		youDanAmount.setAssociationId(orderId);
		youDanAmount.setOperateType("05");
		youDanAmount.setRemark(remark);
		youDanAmount.setAmountType("02");//02 接受保证金
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public int updateYongJin2Fail(Integer orderId, String remark) throws SQLException {
		YouDanAmountDTO youDanAmount = new YouDanAmountDTO();
		youDanAmount.setAmountType("02");
		youDanAmount.setAssociationId(orderId);
		youDanAmount.setOperateType("06");
		youDanAmount.setRemark(remark);
		youDanAmount.setAmountType("02");//02 接受保证金
		return this.updateYouDanAmount(youDanAmount);
	}

	@Override
	public BigDecimal getBaoZhengJinAmount(Map<String, Object> map) throws SQLException {
		return youDanAmountDaoImpl.getBaoZhengJinAmount(map);
	}

	@Override
	public BigDecimal getCommissionAmount(Map<String, Object> map) throws SQLException {
		return youDanAmountDaoImpl.getCommissionAmount(map);
	}

	@Override
	public Integer getYouDanAmountCount(YouDanAmountVO youDanAmount) throws SQLException {
		return youDanAmountDaoImpl.getYouDanAmountCount(youDanAmount);
	}

	
}
